#!/usr/bin/python
# -*- coding: utf-8 -*-
# @version        : 1.0
# @Create Time    : 2025/3/25 14:39
# @File           : task
# @IDE            : PyCharm
# @desc           : 文件描述
from datetime import datetime
from typing import List, Optional

from pydantic import BaseModel, ConfigDict
from core.data_types import DatetimeStr
from apps.base.auth.validate import User


######################
#     辅料需求相关     #
#####################
class TaskNeed(BaseModel):
    ticket_id: str

    need_type: Optional[str] = "辅料"
    name: str

    type: Optional[str] = None
    number: Optional[str] = None
    unit: Optional[str] = None

    remark: Optional[str] = None

    create_user: Optional[str] = None
    update_user: Optional[str] = None


class TaskNeedSimpleOut(TaskNeed):
    model_config = ConfigDict(from_attributes=True)

    id: int
    update_datetime: DatetimeStr
    create_datetime: DatetimeStr


class Task(BaseModel):
    model_config = ConfigDict(from_attributes=True)
    
    ticket_id: str  # 工单编号

    ao_id: str  # AO编号
    ao_name: str  # AO名称
    ao_type: Optional[str] = None  # AO类型，AAO、DISR、FRR、AO等

    status: str  # AO状态，未开始、生产中、已完工

    product_type: str  # 机型
    flight: str  # 架次
    station: str  # 工位
    sub_station: Optional[str] = None  # 二级工位
    position: Optional[str] = None  # 站位
    team: Optional[str] = None  # 班组
    team_leader: Optional[str] = None

    group1: Optional[str] = None  # 分组1
    group2: Optional[str] = None  # 分组2
    tag: Optional[str] = None  # 标签

    start: Optional[DatetimeStr] = None  # 计划开工时间
    end: Optional[DatetimeStr] = None  # 工期
    priority: Optional[int] = 0  # AO生产优先级
    order: Optional[int] = 0  # AO展示排序

    material_match: Optional[bool] = None
    delivery_message: Optional[bool] = None
    pi: Optional[bool] = None

    in_daily_plan: Optional[bool] = None
    in_weekly_plan: Optional[bool] = None

    create_user: Optional[str] = None
    update_user: Optional[str] = None


class TaskNeedOut(TaskNeedSimpleOut):
    model_config = ConfigDict(from_attributes=True)

    task: Task
